package hjslm.Controller.Front;

import java.util.List;

import hjslm.Bean.AdvertisementBean;
import hjslm.Bean.ExcellentStudentBean;
import hjslm.Bean.NavcustomBean;
import hjslm.Bean.ShijuanBean;
import hjslm.Bean.TeacherBean;
import hjslm.Bean.XinwenBean;
import hjslm.Service.IAdvertisementService;
import hjslm.Service.IExcellentStudentService;
import hjslm.Service.INavCustomService;
import hjslm.Service.IShijuanService;
import hjslm.Service.ITeacherService;
import hjslm.Service.IWeixinService;
import hjslm.Service.IXinwenService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import framework.base.common.Pager;
import framework.base.controller.BaseController;

@Controller
@RequestMapping("/home")
public class FHomeController extends BaseController{

	/**
	 * 前台首页控制层
	 */
	private static final long serialVersionUID = 1L;
	
	@Autowired
	IAdvertisementService advertisementService;
	
	@Autowired
	INavCustomService navCustomService;
	
	@Autowired
	IWeixinService weixinService;
	
	@Autowired
	ITeacherService teacherService;
	
	@Autowired
	IExcellentStudentService excellentStudentService;
	
	@Autowired
	IXinwenService xinwenService;
	
	@Autowired
	IShijuanService shijuanService;

	@Override
	public void setLogger() {		
	}
	
	@RequestMapping("/index")
	public ModelAndView index(){
		ModelAndView modelAndView = new ModelAndView("front/home/index");
		List<AdvertisementBean> list = advertisementService.selectList(null);
		modelAndView.addObject("list", list);
		
		List<NavcustomBean> navList  = navCustomService.selectList(null);
		modelAndView.addObject("navList", navList);
		
		modelAndView.addObject("map", weixinService.selectMap());
		
		
		//教师信息
		Pager<TeacherBean> teacherPager = new Pager<TeacherBean>();
		teacherPager.setCountPerPage(5);
		teacherPager = teacherService.selectPage(null, teacherPager);
		modelAndView.addObject("teacherPager", teacherPager);
		
		//学生信息
		Pager<ExcellentStudentBean> studentPager = new Pager<ExcellentStudentBean>();
		studentPager.setCountPerPage(5);
		studentPager = excellentStudentService.selectPage(null, studentPager);
		modelAndView.addObject("studentPager", studentPager);
		
		//最新新闻
		Pager<XinwenBean> xinwenPager = new Pager<XinwenBean>();
		xinwenPager.setCountPerPage(10);
		xinwenPager = xinwenService.selectPage(null, xinwenPager);
		modelAndView.addObject("xinwenPager", xinwenPager);
		
		//最新试卷
		Pager<ShijuanBean> shijuanPager = new Pager<ShijuanBean>();
		shijuanPager.setCountPerPage(10);
		shijuanPager = shijuanService.selectPage(null, shijuanPager);
		modelAndView.addObject("shijuanPager", shijuanPager);
		return modelAndView;
	}

}
